#include "QyRenderLayer.h"
#include "QyRender.h"

using namespace QyRender;

Layer::Layer( QyRender::Painter * painter, const LayerFlags & flags, const qreal & z )
	: p_painter(0), p_flags(flags), p_z(z)
{

	setPainter(painter);

}

Layer::~Layer() {

	setPainter(0);
	qDeleteAll(p_items);

}

void Layer::setPainter( QyRender::Painter * painter ) {

	if ( p_painter == painter )
		return;

	if (p_painter)
		p_painter->removeLayer(this);

	p_painter = painter;

	if (p_painter)
		p_painter->addLayer(this);

}

void Layer::setZ( const qreal & z ) {

	p_z = z;

	if (p_painter)
		p_painter->arrange();

}
